#include <iostream>
#include <cstring>

typedef struct data
{
    int n;
    struct data *next;
}DATA;

//创建头指针
DATA * create()
{
    DATA *head=NULL;
    return head;
}

//创建链表
DATA* build(DATA *head,int a)
{
    DATA *p=new DATA;
    static DATA *q=head;
    p->n=a;
    p->next=head;
    head=p;
    return head;
}

void show(DATA *head)
{
    DATA *p=head->next;
    if(p==NULL)
    {
        printf("Link list is empty\n");
        return;
    }
    int pd=0;
    while(p!=NULL)
    {
        if(pd)
        {
            printf(" ");
        }
        printf("%d",p->n);
        p=p->next;
        pd=1;
    }
    printf("\n");
    return;
}

void Delete(DATA *head,int x)
{
    DATA *p=head->next;
    DATA *q=head;
    int i=1;
    while(p!=NULL)
    {
        if(i==x)
        {
            q->next=p->next;
            delete p;
            printf("delete OK\n");
            return;
        }
        q=p;
        p=p->next;
        i++;
    }
    printf("delete fail\n");
    return;
}

void insert(DATA *head,int x,int y)
{
    DATA *p=head;
    DATA *q;
    int i=1;
    while(p!=NULL)
    {

        if(i>=x)
        {
            q=new DATA;
            q->n=y;
            q->next=p->next;
            p->next=q;
            printf("insert OK\n");
            return;
        }
        p=p->next;
        i++;
    }
    printf("insert fail\n");
    return;

}

void get(DATA *head,int x)
{
    DATA *p=head->next;
    for(int i=1;i<x;i++)
    {
        if(p==NULL)
        {
            printf("get fail\n");
            return;
        }
        p=p->next;
    }
    if(p!=NULL&&x>0)
    {
        printf("%d\n",p->n);
    }
    else
    {
        printf("get fail\n");
    }
    return;
}

int main() {
    DATA *head;
    head=create();
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d", &a);
        head = build(head, a);
    }
    head=build(head,0);
    int m;
    char a[10];
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        scanf("%s",a);
        if(strcmp(a,"show")==0)
        {
            show(head);
        }
        else if(strcmp(a,"delete")==0)
        {
            int x;
            scanf("%d",&x);
            Delete(head,x);
        }
        else if(strcmp(a,"insert")==0)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            insert(head,x,y);
        }
        else if(strcmp(a,"get")==0)
        {
            int x;
            scanf("%d",&x);
            get(head,x);
        }
    }

    return 0;
}
